import type { TagType } from "vant";
import type { DetailMapItemType } from "@/components/CellGroup/types";
import { formatDate } from "@/utils";

/** 流程类型枚举 */
export enum ProcessTypeEnum {
	/** 询价 */
	INQUIRY = 2,
	/** 研发试制、采购申请 */
	PUR = 1,
	/** 用章使用申请 */
	STAMP = 0
}

/** 待办已办tab 枚举 */
export enum TabEnum {
	/** 待办 */
	PENDING = 0,
	/** 已办 */
	COMPLETED = 1,
	/** 已发起 */
	CREATED = 2
}

/** tab 映射 */
export const TAB_MAP = {
	[TabEnum.PENDING]: "待办",
	[TabEnum.COMPLETED]: "已办",
	[TabEnum.CREATED]: "已发起"
};

/** 流程类型对应表单页面、审批页面 */
export const PROCESS_TYPE_MAP = {
	[ProcessTypeEnum.INQUIRY]: "/purchaseInquiry/form",
	[ProcessTypeEnum.PUR]: "/pur/form",
	[ProcessTypeEnum.STAMP]: "/stampApply/form"
};

/** 审批状态枚举 */
export enum ApprovalStatusEnum {
	/** 已完成 */
	Completed = "已完成",
	/** 进行中 */
	InProgress = "进行中"
}

/** 审批状态映射 */
export const ApprovalStatusMap: {
	[x in ApprovalStatusEnum]: {
		text: string;
		tagType: TagType;
	};
} = {
	[ApprovalStatusEnum.InProgress]: {
		text: "进行中",
		tagType: "primary"
	},
	[ApprovalStatusEnum.Completed]: {
		text: "已完成",
		tagType: "success"
	}
};

/** 审批详情映射 */
export const APPROVE_DETAIL_MAP: DetailMapItemType[] = [
	{ label: "审批名称", field: "title" },
	{ label: "提交人", field: "submit" },
	{
		label: "提交时间",
		field: "submitTime",
		formatter: (value: string) => {
			return formatDate(value, "YYYY-MM-DD");
		}
	},
	{ label: "提交人部门", field: "org" },
	{ label: "状态", field: "status", slotName: "status" }
];
